# Gilardi, Fabrizio, "The Temporary Importance of Role Models for Women's Political Representation", American Journal of Political Science
# Code to replicate Table SI3 (Replication of Table 1, without control variables except year dummies)
# gilardi@ipz.uzh.ch, 2014-06-24

# Set working directory
setwd("../Data/")

# Load packages
library(texreg)

# Load data
d <- read.csv("dataset-full.csv")


###################
# Estimate models #########################################
###################

out.1w <- glm(n.women.cand ~ sl.autob.n.women.elected + as.factor(year), data=d, family="poisson")
summary(out.1w)

out.2w <- glm(n.women.cand ~ sl.autob.n.women.elected + sl.autob.n.women.elected*as.factor(year), data=d, family="poisson")
summary(out.2w)

out.3w <- glm(n.women.cand ~ n.women.elected.lagged + n.women.elected.lagged*as.factor(year), data=d, family="poisson")
summary(out.3w)

out.4w <- glm(n.women.cand ~ sl.autob.n.women.elected + n.women.elected.lagged + n.women.elected.lagged*as.factor(year) + sl.autob.n.women.elected*as.factor(year), data=d, family="poisson")
summary(out.4w)



##############
# Make table ########################################
##############

var.names <- c(
	"(Intercept)",
	"Spatial lag",
	seq(1978, 2010, 4),
	"Spatial lag $xx$ 1978",
	"Spatial lag $xx$ 1982",
	"Spatial lag $xx$ 1986",
	"Spatial lag $xx$ 1990",
	"Spatial lag $xx$ 1994",
	"Spatial lag $xx$ 1998",
	"Spatial lag $xx$ 2002",
	"Spatial lag $xx$ 2006",
	"Spatial lag $xx$ 2010",
	"Nr. xfemale elected ($t-1$)",
	"Nr. xfemale elected ($t-1$) $xx$ 1978",	
	"Nr. xfemale elected ($t-1$) $xx$ 1982",	
	"Nr. xfemale elected ($t-1$) $xx$ 1986",	
	"Nr. xfemale elected ($t-1$) $xx$ 1990",	
	"Nr. xfemale elected ($t-1$) $xx$ 1994",	
	"Nr. xfemale elected ($t-1$) $xx$ 1998",	
	"Nr. xfemale elected ($t-1$) $xx$ 2002",	
	"Nr. xfemale elected ($t-1$) $xx$ 2006",	
	"Nr. xfemale elected ($t-1$) $xx$ 2010"
)

model.names <- c("(1)", "(2)", "(3)", "(4)")

texreg(list(out.1w, out.2w, out.3w, out.4w), single.row=T, center=T, dcolumn=T, custom.coef.names=var.names, custom.model.names=model.names)




